const Department = require('../models/department_model')
const jsonResult = require('../utils/JSON')

// 科室-获取科室列表
exports.departmentListGet = async (ctx,next) => {
    try {
        let { body } = ctx.request.body;
        console.log(body);
        let res = await Department.departmentListGet(body);
        console.log(res,"departmentListGet");
        ctx.body = jsonResult.resultSuccessJson(undefined, undefined,res)
    } catch (error) {
        console.log(error)
        ctx.body = jsonResult.resultErrorJson(undefined, undefined);
    }
}

// 科室-科室添加
exports.departmentAdd = async (ctx)=>{
    try{
        let { body } = ctx.request.body;
        let res = await Department.departmentAdd(body);
        ctx.body = jsonResult.resultSuccessJson(undefined, undefined,res)
    }catch(error){
        console.log(error);
        ctx.body = jsonResult.resultErrorJson(undefined, undefined);
    }
}
// 科室-科室信息修改
exports.departmentUpdate = async (ctx)=>{
    try{
        let { body } = ctx.request.body;
        let res = await Department.departmentUpdate(body);
        ctx.body = jsonResult.resultSuccessJson(undefined, undefined,res); 
    }catch(error){
        console.log(error);
        ctx.body = jsonResult.resultErrorJson(undefined, undefined);
    }
}
// 科室-删除科室
exports.departmentDelete = async (ctx)=>{
    try{
        let { body } = ctx.request.body;
        let res = await Department.departmentDelete(body);
        ctx.body = jsonResult.resultSuccessJson(undefined, undefined,res);
    }catch(error){
        console.log(error);
    }
}